From 2d9284c4a58976f7549729b9e2129151bd8a9bc7 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 12 Dec 2007 12:02:01 +0000 Subject: [PATCH] ioemu/qemu vga: save and restore vram buffer (take 2) The existing stdvga driver from xen-unstable tools/ioemu/hw/vga* does not save the emulated VGA memory contents. The symptoms include video malfunction after restore, including black screen (which can often be fixed by asking the guest to redraw) but also missing font setup etc. The attached patch fixes this by saving the entire VGA memory buffer, just like the Xen ioemu Cirrus emulator does. Signed-off-by: Ian Jackson --- tools/ioemu/hw/vga.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/ioemu/hw/vga.c b/tools/ioemu/hw/vga.c index cb34f289fb..17538bbddc 100644 --- a/tools/ioemu/hw/vga.c +++ b/tools/ioemu/hw/vga.c @@ -1742,6 +1742,7 @@ static CPUWriteMemoryFunc *vga_mem_write[3] = { static void vga_save(QEMUFile *f, void *opaque) { VGAState *s = opaque; + uint32_t vram_size; #ifdef CONFIG_BOCHS_VBE int i; #endif @@ -1783,17 +1784,21 @@ static void vga_save(QEMUFile *f, void *opaque) #else qemu_put_byte(f, 0); #endif + vram_size = s->vram_size; + qemu_put_be32s(f, &vram_size); + qemu_put_buffer(f, s->vram_ptr, s->vram_size); } static int vga_load(QEMUFile *f, void *opaque, int version_id) { VGAState *s = opaque; int is_vbe, ret; + uint32_t vram_size; #ifdef CONFIG_BOCHS_VBE int i; #endif - if (version_id > 2) + if (version_id > 3) return -EINVAL; if (s->pci_dev && version_id >= 2) { @@ -1839,6 +1844,13 @@ static int vga_load(QEMUFile *f, void *opaque, int version_id) if (is_vbe) return -EINVAL; #endif + if (version_id >= 3) { + /* people who restore old images may be lucky ... */ + qemu_get_be32s(f, &vram_size); + if (vram_size != s->vram_size) + return -EINVAL; + qemu_get_buffer(f, s->vram_ptr, s->vram_size); + } /* force refresh */ s->graphic_mode = -1; @@ -2052,7 +2064,7 @@ static void vga_init(VGAState *s) { int vga_io_memory; - register_savevm("vga", 0, 2, vga_save, vga_load, s); + register_savevm("vga", 0, 3, vga_save, vga_load, s); register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s); -- 2.30.2